package com.lagou.rpc.consumer.component;

import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.consumer.zookeeper.ZkNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author mcl
 * @date 2021/7/31 2:25 下午
 * @description
 */
@Component
@Slf4j
public class ZookeeperTask {
    @Autowired
    private ZkNode zkNode;
    @Autowired
    private RpcClientProxy rpcClientProxy;

    @Scheduled(cron = "0/5 * * * * *")
    private void uploadZkNodeState() {
        rpcClientProxy.getClients().forEach(rpcClient -> {
            zkNode.uploadZkNodeState(rpcClient);
        });
    }
}
